<layout name="no-slide"/>

<if condition="$cartTeam['progStatus']==0" >
<h3 class="tc">本期已结束</h3>
<section class="block-item">
  <h3 class="title">参与名单</h3>
  <div class="content">
    <table class="table">
      <thead>
        <th>姓名</th>
        <th>车辆品牌</th>
        <th>联系方式</th>
      </thead>
      <tbody>
        <volist name="cartTeam['userLists']" id="vo">
        <tr>
          <td>{$vo.name}</td>
          <td>{$vo.brand}</td>
          <td>{$vo.tel}</td>
        </tr>
        </volist>
      </tbody>
    </table>
  </div>
</section>
<else/>

<section class="block-item">
  <h3 class="title">{$cartTeam.title}</h3>
  <div class="content">{$cartTeam.content}</div>
</section>

<section class="block-item">
  <h3 class="title">结束日期</h3>
  <div class="content">{$cartTeam.end_time|date="Y-m-d h:i:s", ###}</div>
</section>

<section class="block-item">
  <h3 class="title">报名审车团</h3>
  <form id="form" class="form form-simple" method="post" action="/index.php/Home/CartTeam/save">
    <div class="form-item fun-grid">
      <label class="col-md-3">姓名</label>
      <p class="col-md-9"><input type="text" name="name"></p>
    </div>
    <div class="form-item fun-grid">
      <label class="col-md-3">车辆品牌</label>
      <p class="col-md-9"><input type="text" name="brand"></p>
    </div>
    <div class="form-item fun-grid">
      <label class="col-md-3">车牌号</label>
      <p class="col-md-9"><input type="text" name="code"></p>
    </div>
    <div class="form-item fun-grid">
      <label class="col-md-3">联系电话</label>
      <p class="col-md-9"><input type="tel" name="tel"></p>
    </div>
      <div class="form-item fun-grid">
        <input type="hidden" name="ct_id" value="{$cartTeam.id}">
        <input type="hidden" name="sid" value="{$_GET['sid']}">
        <p class="submit col-md-offset-3"><button class="btn btn-blue" type="submit">报名审车</button></p>
      </div>
  </form>
</section>
</if>

<script type="text/javascript">
  (function(){
    
    // 加载modal.js
    GH.load( "js", "js-modal", "__COMMON__/js/modal.js" );
    var oForm = GH.$( "#form" ),
        formControl = GH.$$( "#form input" );
    oForm && oForm.addEventListener( "submit", fnSubmit, false );
    function fnSubmit( event ) {
      event.preventDefault();
      checkForm() && postForm.call( this );
    };
    function checkForm() {
      var canpost = true;
      [].forEach.call(formControl, function(item, index) {
        if ( !!!item.value.trim() ) {
          GH.showMessage( "麻烦填写完整信息~~" );
          canpost = false;
          return false;
        };
      });
      return canpost;
    };
    function postForm() {
      var fm = GH.serialize( "form" );
      var url = this.getAttribute( "action" );
      GH.ajax(url, fm, function( data ) {
        modal.alert({
          title: "报名结果",
          text: data.msg
        });
      });
    };
  })();
</script>